package org.theqcp.wow.api.wowarmory.parsers;

/**
 * Useful base class for parser.
 * 
 * @author angryundead
 *
 */
public class AbstractParser {
	
	protected Double convertSafeDouble(String input) {
		
		Double d = 0.0;
		
		//bail early!
		if(input == null || input.isEmpty()) return d;
		
		try {
			d = Double.valueOf(input);
		} catch (NumberFormatException nfe) {
			d = 0.0;
		}
		
		return d;
	}
	
	protected Integer convertSafeInt(String input) {
		
		Integer i = 0;
		
		//bail early!
		if(input == null || input.isEmpty()) return i;
		
		try {
			i = Integer.valueOf(input);
		} catch (NumberFormatException nfe) {
			i = 0;
		}
		
		return i;
	}
}
